import java.util.Scanner;

public class StringDemo4 {
    public static void main(String[] args) {
        //1.定义两个变量记录正确的用户名和密码
        String rightUsername = "zhangsan";
        String rightPassword = "123456";

        Scanner sc = new Scanner(System.in);
        //2.键盘录入用户名和密码
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名");
            String Username = sc.next();
            System.out.println("请输入密码");
            String Password = sc.next();
            //3.比较
            if (rightUsername.equals(Username) && rightPassword.equals(Password)) {
                System.out.println("用户登录成功");
                break;
            } else {
                if (i == 2) {
                    System.out.println("”账号" + Username + "被锁定，请联系客服：xxx-xxxxx");
                } else {
                    System.out.println("用户登陆失败，用户名或密码错误，您还剩下" + (2 - i) + "次机会");
                }
            }
        }
    }
}
